package com.talent.service.iot.mqtt.model.payload;

import com.talent.service.iot.mqtt.model.entity.TlTopic;

import java.util.List;

/**
 * @ClassName：TlMqttConnectPayload
 * @Author: hszhou
 * @Date: 2024/11/25 14:24
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
public class TlMqttSubAckPayload {

    private int[] codes;

    public int[] getCodes() {
        return codes;
    }

    public void setCodes(int[] codes) {
        this.codes = codes;
    }

    public TlMqttSubAckPayload(int[] codes) {
        this.codes = codes;
    }

    public static TlMqttSubAckPayload of(List<TlTopic> topics) {
        int[] codes = new int[topics.size()];
        for (int i = 0; i < topics.size(); i++) {
            codes[i]=topics.get(i).getQos();
        }

       return new TlMqttSubAckPayload(codes);
    }

}
